perm filename F8[F8,ALS]2 blob
sn#307780 filedate 1977-09-30 generic text, type C, neo UTF8
COMMENT ā VALID 00022 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00003 00002 Status as of August 1, 1977
C00017 00003 * RAM and SCRATCHPAD assignments. Multiple jumps
C00028 00004 * Storage map
C00034 00005 * TREE MOBS PLY0 COL0 PLOC KLOC ELOC PLYT PLYD PLYH START
C00038 00006 * RASC SCRA EMPTY CAQ MPYR
C00043 00007 * FKT GMEN RFJN LFJN STMV
C00047 00008 * NEXT FIND RFJ LFJ RBJ LBJ
C00053 00009 * JUMT AFTC
C00055 00010 * AFT MAKE OKMV PMRT
C00058 00011 * RFN LFN RBN LBN NORT NORF NOR2 NOR3 NOR4
C00061 00012 * SELECT SELE
C00065 00013 * JUMP
C00071 00014 * NORM FORE
C00073 00015 * EVAL
C00077 00016 * SQIN SQOU MVIN
C00082 00017 * TELL
C00084 00018 * BOOK
C00087 00019 * MEN KING REDP BLKP
C00093 00020 *MAP Code to convert joystick reading into cursor position on board.
C00097 00021 * Code to verify that indicated piece can, in fact, move.
C00102 00022 * Guli's code
C00105 ENDMK
Cā;
Status as of August 1, 1977
The code that follows is the checker playing portion only and does not
include the interface coding that is required to put the program onto the
machine. This interface portion is being written by Guli Aboobaker and
seems to present some special problems that have not been successfully
solved. Apparently, most of the present operating programs do not have to
meet these problems because of the relatively small amount of computing
that they require.
The present indications are that considerable paring will have to be done
to the code that follows in order to meet the desired space limitation.
It seemed best to write code for all of the desired features first, and
then to assess the penalties involved in paring the code in different ways
to meet space requirments. Most of this code has been debugged so that it
will compile but no operating runs have yet been made.
General Remarks
We envision three levels of play which are personified by calling them
Robot Tom, Robot Dick and Robot Harry. Robot Tom will be the weakest
player. The single letters T, D and H will be used to designate these
players. Depending upon what is decided as to the amount of audio and
visual text that can be generated, these three levels might be further
identified by calling the lowest level "Helpful Robot Tom", the next as
"Silent Robot Dick" and the highest level as "Mighty Robot Harry", and the
board could be displayed in diffrent colors for the three different
levels.
Under normal circumstances, the details of how these levels are adjusted
would be kept from the player. He would simply be asked to indicate his
preference by typing a T, D, or H, with any other character (including the
space bar) being taken as indicating Tom by default. In fact, all
questions will have a default answer so that a very young child can be
instructed to hit the space bar each time a question is asked until the
board appears and then to make his move. The literate player will be
advised to start with Tom and to progress to Dick and then to Harry as
desired.
The next question will be with reference to the mode of play, that is if
moves are to be entered by typing numbers or by using the joystick. Here
again, the question will be posed so that any key other than a specified
one will mean "joystick". When the joystick is used the position of the
cursor on the board image will be restricted to the playing squares and
it will jump from playing square to the next nearest playing square as
the joystick is moved, thus preventing the inexperienced from trying to
move a piece to a non-playing square.
The final question will relate to which side is to play first and again
any key other than a specified one will mean that the player wants to play
first. If the player's choice is to play first, then the black pieces
will appear at the bottom of the screen, othewise the red pieces will be
at the bottom. That is, the player's pieces will always be at the bottom
and the standard checker convention of black playing first will thus be
automatically enforced.
The levels of play would be set by changes to the depth of ply to which
the search would be allowed to go and perhaps by the way that stored moves
would be used.
For the truely expert checker player, there should be a way to set the
play to even higher levels. Actually, this will not be difficult to do
but unfortunately the playing time may be unduely long, and it probably
would be unwise to let the casual user get into trouble by making these
levels readily available. The good checker player might welcome this
provision.
The user could be advised of this possibility in the literature supplied
with the cartridge and could be told to write in for information as to how
this is done. This could be used to generate a list of interested users
for a mailing list. These people would be prime candidates for other
cartridges and perhaps for a new model of the Video Brain when one is
developed.
It would also be possible to allow the user to set up any initial board
conditions that he choses, (a checker puzzle for example) rather than
having to start each game from scratch. Even the casual user might like
this feature as it would allow him to stop playing in the middle of a game
and to continue the interrupted game as a later time. To make this easy
to do the program should be able to list the board condition in standard
checker notation (so the user can copy it) rather than forcing the user to
generate this list himself or forcing him to make a picture of the board.
If the machine is to play black on starting a new game then 7 possible
first moves will be available in condensed form and a random choice is
made. Perhaps for the best player, the choice could be limited to 2 or 3
of the best ones with the prefered ones repeated. If opponent plays black
then there will be stored several, probably 4, replies.
Moves are stored in a highly compressed form. Since there are seldom more
than 16 possible moves, and certainly many fewer in the opening, 4 bits
are sufficient to specify a move from any given starting location, so
moves can be packed two to the byte. By having the location of the stored
bytes computable from the number specifying the first move one can, in 7
bytes store 2 replies for each possible first move, or 4 replies in 14
words If space permits one could also store perhaps 2 counter replies each
to these replies, this taking 28 additional words. This, in effect will
cause the machine to play a different game almost every time, An astute
player can, however, note the machine play, and thus acquire a repertoire
of good early-game moves.
Piece representation
King's crown Red piece Black piece Cursor
________ ________ ________ ________
| | | | | | | xx |
| x xx x | | | | | | xx |
| xxxx | | | | | | xx|
| xx | | | | | | x|
| | | xxxx | | xxxx | | |
| | | xxxxxx | | x x | | |
| | | xxxxxx | | x x | | |
| | | xxxxxx | | x x | | |
| | | xxxx | | xxxx | | |
|________| |________| |________| |________|
The x's indicate red.
The King's crown is the same for both red and black pieces and
is put in the space above the piece.
The cursor is moved by a joy stick but it jumps from playing square to
playing square only, landing always on the nearest playing square to its
actual indicated position. When an attach key is hit, to signal a piece
to be moved, the piece blinks but does not follow the cursor until a
deposit key is hit and then only after the legality of the move has been
verified. This relieves the need for there to be textual signals to the
player so that pre-school children can play. Textual abmonitions and
confirmations may still be desirable as a teaching device, and by way of
explanation for literate players.
Move verification
When the program has made its move and reported this to the player, it
proceeds at once to compute all possible move available to the player.
When the player points to the piece he wants to move it will be then
possible to test at once as to whether this piece can in fact move. If it
cannot some sort of signal will be given, perhaps a buzz, while if it can
move the piece will start to blink.
The player will then move the pointer to the square to which he wishes to
move the piece and again the validity of this destination will be checked.
* RAM and SCRATCHPAD assignments. Multiple jumps
Tree data will be kept in RAM in blocks of 16 bytes, one for each ply
depth.
These data will occupy 256 bytes starting at a location DLOC which is
presently defined as H'0E10', thst is in locations H'0E10' thru H'0F0F'.
At the start of a game the first two blocks will be
loaded with the conditions that relate to a game with the machine playing
BLACK. If the player elects to play BLACK then the board conditions after
his move are loaded into the second block. Thereafter the second block
will be used as the board to start the tree search and the machines reply
will be returned in the first block.
Data within each block will be located as follows:
Bytes Contents
0 thru 3 ACTIVE pieces
4 thru 7 PASSIVE pieces
8 thru 11 KINGS
12 MOVE byte
13 Piece debit (3), JUMP (1), Byte # (2), Direction (2).
14 Score, Active's material advantage.
15 Score, Active's positional advantage and Ply debit
When blocks of data are to be operated on, they are moved from RAM into 16
Scratchpad registers starting at a location defined by LISU PLOC where
PLOC is presently defined to be 3 (that is registers 24 thru 39).
The piece debit is given special treatment, since two debits must be
carried forward, that for the active side and that for the passive side.
Since the sides will be reversed when the SC is put back into RAM, the
piece debit in SC is gotten from the previous block, not the current one
from which the rest of the data is gotten. The piece debit in SC thus
refers to the current passive side while thAt in RAM refers to the active
side. The debit account in SC is increased by 1 for each promotion made
by the active side and increased by 2 for each piece captured and 3 for
each king captured. At the start of each play, the piece debit records
for the board record from which the player moves and the resulting board
from which the machine plays will be normallized by subtracting the
smaller value fron both records, and by limiting the maximum value to 3.
During the tree search the maximum value also be limited to 7 to permit
packing in 3 bits.
A similar situation exists as to the score since two sets of scores are
needed for alpha-beta pruning. Here also the scores that are brought
forward as one goes along the tree are gotten from the previous board.
The FIND routine is then entered and at that time all possible moves are
determined, the count of the number of moves is accumulated in SC 2.
If the decision is made to go forward, this value is transfered to SC 7,
**** 7 will be used for something else
overwriting the value saved at the earlier board. If, on the contrary,
the decision is to evaluate then the value is retained in SC 2 only so
that the value in SC 7 is not distroyed.
The other data gotten by the FIND routine, namely the first found MOVE
byte and a record of its J value, its Byte # and its Direction is written
back into the current RAM block.
Scratchpad registers defined by LISU ELOC where ELOC is presently set at 5
are used for EMPTY as created by code EMPT with O'50' and O'57' left blank
as guards.
Scratchpad registers O'57' THRU O'67' are presently unassigned.
Scratchpad registers O'70' thru O'77' are used for a push-down stack, to
be used for nesting subroutines to a maximum depth of 3.
After processing the data in SC is moved back to RAM in the next block with
the ACTIVE and PASSIVE pieces reversed in position.
Scratchpad registers 0 thru 8 are normally used as follows:
Register Usage
0 general purpose
1 general purpose
2 King move flag during SELECT and MOBILITY during FIND
3 Move byte during generation
4 Byte pointer (bits 2 and 3 from FLAG byte, shifted right by 2)
5 Byte identification 0 thru 4, piece debit in 5 thru 7
6 MOVE bit extracted from MOVE
7 Color of ACTIVE (0 if Black, H'FF' if White)
8 Reserved for dumping AC before UPDAT
Data from RAM is transfered into scratchpad registers starting at LISU
PLOC with ACTIVE and PASSIVE have an LISU address of PLOC, while KINGS and
special data have an LISU address of KLOC. The empty squares on the board
are computed fresh each time a board is under study and are stored with an
LISU of ELOC.
Multiple-jump provisions
Multiple jumps pose a special problem, particularly if they are forked.
It seems unwise to provide the space on every move to keep the necessary
information in the remote possibility that it might be a multiple jump.
So some depth of ply is sacrificed when multiple jumps are encountered
to leave the necessary space.
When a jump move is encountered we anticipate a possible continuing jump
and store the resulting board (after the first jump) in the next two
blocks, in the first of these in regular form for use if the jump should
not continue, and in the second of these without reversing the sides so
that the previously active side is still active. An attempt is then made
to find a continuation from this second with the moving piece restricted
to the one participating in the first jump. Incidentally, if the first
jump should cause the piece to arrive at its king row and if the piece
were not already a king then the piece is promoted and no preparaations
for continuing need be made.
If a continuing jump is found then this fact is signalled by storing a
flag in the otherwise unused right half of the MOBS byte associated with
the second block and the space normally used for the MOVE byte and the
direction pointer in the first of the two new blocks is used to save the
identification of the moving piece. The tree analysis then continues from
the second block. On back-up a test must always be made of the flag in
MOBS space and appropiate action taken if it is set. This action involves
looking for a forked jump continuation fron this point and if one is not
found in backing up two blocks to then look for a remaining move from
this earlier board.
If no continuation is found, then the code backs up to the first of the
two mentioned blocks and the temporarily used space is over-written with
it usual contents, and the analysis continues from here.
It should be noted that a double jump thus takes the space normally
allotted to 3 levels of ply and so restricts the maximum depth for which
there space along this particular path by 2 levels. For example, an
exchange of double jumps, as sometimes occures, limits the maximum depth
along this path from the usual limit of 13 to 9.
* Storage map
_______________________________________________________________
Image ar|_______________________________|_______________________________|
10 |_______________________________|_______________________________|
lines |_______________________________|_______________________________|
per |_______________________________|_______________________________|
__row___|_______________________________|_______________________________|
Ply ar. |Active pieces |Passive pieces | Kings |Move,#, Score |
| 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F |
H'0C00' | Used by RES. | | | |
H'0C10' | ___|_______________|_______________|_______________|
H'0B20' |___________|___|_______________|_______________|_______________|
H'0C30' | Row 1 of the | board image | | |
|_______________|______________ |_______________|_______________|
H'0C80' | Row 2 | | | |
|_______________|_______________|_______________|_______________|
H'0CD0' | Row 3 | | | |
|_______________|_______________|_______________|_______________|
H'0D20' | Row 4 | | | |
|_______________|_______________|_______________|_______________|
H'0D70' | Row 5 | | | |
|_______________|_______________|_______________|_______________|
H'0DC0' | Row 6 | | | |
|_______________|_______________|_______________|_______________|
H'0E10' | Players board | | | |
H'0E20' | PLY 0 | | | |
H'0E30' | Ply 1 | | | |
H'0E40' | Ply 2 | | | |
H'0E50' | Ply 3 | H'0E5F' thru | | |
H'0E60' | PLY 4 | H'0ECE' | | |
H'0E70' | PLY 5 | overwritten | | |
H'0E80' | PLY 6 | by text display | |
H'0E90' | PLY 7 | to tell player| | |
H'0EA0' | PLY 8 | that it is | | |
H'0EB0' | PLY 9 | his move | | |
H'0EC0' | PLY 10 | Overwritten | by temp info | |
H'0ED0' | PLY 11 | Overwritten | by information| regarding |
H'0EE0' | PLY 12 | possible player's moves | |
H'0EF0' |_PLY 13________|_____"______"__|____"__________|_______________|
H'0F00' |___Mobility____|_______________|_______________|___|_______COL0|
H'0F10' | Row 7 of the | board image | | |
|_______________|_______________|_______________|_______________|
H'0F60' | Row 8 | | | |
|_______________|_______________|_______________|_______________|
H'0FB0' | Available | |_______________|_______________|
H'0FC0' |_______________|_______________|
Scratchpad Assignments
Octal Usage
0 General purpose
1 General purpose
2 Mobility during FIND and King move flag during SELECT
3 Move byte during FIND and Move bit during SELECT
4 Byte number and direction
5 K bit and move direction
6 Initial move bit
7 Color, (from H'0F0F' initially and updated in step with ply depth
10 Reserved for the interrupt routine
11 J
12 H high order byte
13 H low order byte
14 K high order byte
15 K low order byte
16 Q, high order
17 Q, low order
20
21
22
23
24
25 Interrogate last 6 bits for random number
26
27
30 Active pieces, 1st byte
31 Active pieces, 2st byte
32 Active pieces, 3rd byte
33 Active pieces, 4rd byte
34 Passive pieces, 1st byte
35 Passive pieces, 2nd byte
36 Passive pieces, 3rd byte
37 Passive pieces, 4th byte
40 Kings, 1st byte
41 Kings, 2nd byte
42 Kings, 3rd byte
43 Kings, 4th byte
44 Move byte
45 Byte identifying data
46 Score, high order
47 Score, low order
50 EMPTY guard byte (all zero's)
51 EMPTY 1st byte
52 EMPTY 2nd byte
53 EMPTY 3rd byte
54 EMPTY 4th byte
55 EMPTY guard byte )all zero's)
56
57
60
61
62
63
64
65
66
67
70
71
72
73
74
75
76
77
* TREE MOBS PLY0 COL0 PLOC KLOC ELOC PLYT PLYD PLYH START
*
*RAM assignments
TREE EQU H'0E10' Tree data (15 blocks of 16 bytes each)
PLMD EQU H'0EC0' Saved info during reading of players move
PLMV EQU H'0ED0' Overlay region used for player's moves
MOBS EQU H'0F00' Mobility and DJ flags (14 bytes)
PLY0 EQU H'0F0E' Place for player's ply depth choice
COL0 EQU H'0F0F' Place for color choice (next after PLY0)
*
*Scratch pad assignments
PLOC EQU 3 LISU value for ACTIVE and PASSIVE
KLOC EQU 4 LISU value for KING's and special data
ELOC EQU 5 LISU value for EMPTY's area
ISA EQU O'30' ISAR value for active area
ISP EQU O'34' ISAR value for passive
ISK EQU O'40' ISAR value for kings
ISE EQU O'51' ISAR value for empty (with offset)
*Mimimum ply depths
PLYT EQU H'FE' Ply depth for Robot Tom (stored as neg.)
PLYD EQU H'FD' Ply depth for Robot Dick
PLYH EQU H'FC' Ply depth for Robot Harry
*
ORG H'1000'
*Set up initial boards both in SC and in blocks 0 and 1
START LISU PLOC
LISL 0
LI H'FF' Full double row of pieces
LR I,A First byte of ACTIVE
LI H'F0' 1 row only
LR I,A Second byte of active
CLR
LR I,A Part of board with no active pieces
LR I,A Part of board with no active pieces
LR I,A Part of board with no passive pieces
LR I,A Part of board with no passive pieces
LI H'F' 1 row only (in second half of byte)
LR I,A byte of PASSIVE
LI H'FF' Full double row of pieces
LR I,A Last byte with Passive pieces
LISU KLOC
LISL 0
CLR
LR I,A 4 king bytes next (all empty)
LR I,A
LR I,A
LR I,A
LI H'F0' The 4 bits for pieces that can move RF
LR I,A The MOVE byte
LIS H'4' BYTE # 1 RF normal move with no piece debit
LR I,A
LI H'80' Set score at -128 (lose, unless move is found)
LR I,A
CLR With position advantage of 0
LR I,A
DCI PLY0 Location to store ply depth number
LIS PLYT The minimum setting for PLY0 (presently -2)
ST
CLR
LR 7,A Set for black to be active
ST Save so 7 can be freed as required
DCI TREE Set to start of data space (now H'0E10')
LR H,DC Note: H always points to start of a block
PI SCRA Ready for opponents move if he elects BLACK
PI SCRA Ready for Machine to play BLACK
LR DC,H
*Now ask for side election or opponents first move
*These are stored in COL0 and PLY0.
*NOTE THAT REG.7 AND 8 ARE NO LONGER SAFE.
* RASC SCRA EMPTY CAQ MPYR
*
* Subroutine to move data from RAM to S O'30' thru O'47' with the data for
* S O'30' thru O'43' coming from the current block. Data for O '44' thru
* O'47' is from the previous block, with some items deleted.
*
RASC LR K,P Save return address
LISU PLOC SC buffer with Active and Passive
LISL 0
LIS H'8'
LR 0,A
PI RASL
LISU KLOC SC buffer with Kings
LISL 0
LIS H'4'
LR 0,A
PI RASL
LI H'F1' Rest of data from earlier block
ADC
CLR Zero the MOVE byte
LR I,A
LM
NI H'E0' Save Piece debit only
LR I,A
LM
LR I,A Keep both SCORE bytes
LM
LR I,A
PK
*
RASL LM
LR I,A
DS 0
BNZ RASL
POP
*
*Subroutine to move 16 bytes from SC O'30' thru O'47' to RAM direct.
SCRD LR K,P
LISU PLOC
LISL 0
LIS H'8'
LR 0,A
PI SCRL
LISU KLOC
LISL 0
LIS H'8'
LR 0,A
PI SCRL
PK
*
*Subroutine to move 16 bytes from SC O'30' thru O'47' to RAM, reversing
*ACTIVE and PASSIVE and deleting some items
SCRA LR K,P
LISU PLOC
LISL 4
LIS H'4'
LR 0,A
PI SCRL
LISL 0
LIS H'4'
LR 0,A
PI SCRL
LISU KLOC
LISL 0
LIS H'4'
LR 0,A
PI SCRL
LR A,I To index only
CLR Zero MOVE byte
ST
LR A,I
NI H'E0' Save piece debit only
LR A,I
ST Save both SCORE bytes
LR A,I
ST
PK
*
SCRL LR A,I
ST
DS 0
BNZ SCRL
POP
*
*To compute 4 bytes which show the empty squares on the board and store
*them in O'51' thru O'54' with O'50' and O'55' set to zero as guards.
*Note especially that the EMPTY locations are displaced relative to ACTIVE.
EMPTY LISU ELOC
LISL 0
CLR
LR S,A Make sure guard byte is empty
LISU PLOC Start with ACTIVE
LIS H'4'
LR 0,A
BR EMP3
EMP2 LR A,IS
AI H'30' Actually subtracting 16
LR IS,A
EMP3 LR A,S
LR 1,A
LR A,IS
AI 4
LR IS,A
LR A,S
AS 1
LR 1,A
LR A,IS
AI H'D' Add 13 to get to the correct EMPTY location
LR IS,A
LR A,1
COM Reverse 1's and 0's
LR S,A
DS 0
BNZ EMP2
CLR
LR S,A Upper guard byte
POP
*
*Subroutine to count bits in 0 and return count in A
*Uses registers 0 and 1
CAQ CLR
LR 1,A
LR A,0
BR CAQ3
CAQ2 DS 1
AI H'FF'
NS 0
LR 0,A
CAQ3 BNZ CAQ2
LR A,1
COM
INC Make it into a true positive number
POP
*
*Subroutine to multiply 2 positive binary numbers (the smaller in SC 1 and
*the larger in SC 2) by Russian multiplication. SC 0 is used to accumulate
*the product. This code may be used at only one place and can probably be
*written in line at that place with some saving of space.
*
MPYR CLR
LR 0,A To accumulate the product
LR A,1
MPY1 NI H'1' Is the rightmost bit a 1?
BZ MPY2 No
LR A,2
AS 0
LR 0,A
MPY2 LR A,2
SL 1
LR 2,A
LR A,1
SR 1
LR 1,A
BNZ MPY1 Product is not complete
POP
* FKT GMEN RFJN LFJN STMV
*
*Subroutine to limit pieces to KINGS depending on direction and color
FKT LR K,P
CLR
AS 7
BR FK1
BKT LR A,7 Test sides for backward move
COM
FK1 BZ FK2 NORMAL pieces can move
LISU KLOC KINGS only can move
LR A,S
NS 3
LR 3,A
BZ FK3 No RF OR LF moves from this byte
FK2 LR A,3
NS 3 To set status
FK3 PK
*
FJET LR K,P
LIS H'1'
BR BJE2
BJET LI H'FF'
BJE2 AS 4
AI ISE
LR IS,A
LR A,S
PK
*
*Subroutine to get byte of ACTIVE pieces
GMEN LR K,P
LR A,4
AI ISA Start of active area
LR IS,A
LR 5,A Save it here temporarily
LR A,6
CI H'7' Is this an attempted continuation?
BZ GME2 Yes, 3 is already set
CI H'1' Maybe back up to test for forked continuation
BZ GME2
LR A,S
LR 3,A
GME2 PK
*
*Subroutine used both by RFJ and RFN
RFJN LR K,P
LR A,I
SL 4
LR 0,A
LR A,S
SR 4
SR 1
AS 0
NS 3
LR 3,A The RFJ or RJ byte
PK
*
*Subroutine used both by LFJ and LFN
LFJN LR K,P
LR A,I
SL 4
SL 1
LR 0,A
LR A,S
SR 4
AS 0
NS 3
LR 3,A The LFJ or LFN byte
PK
*
*Subroutine used both by LBJ and LBN
LBJN LR K,P
LR A,D
SL 4
LR 0,A
LR A,S
SR 4
SR 1
AS 0
NS 3
LR 3,A
PK
*
*Subroutine used both by RBJ and RBN
RBJN LR K,P
LR A,D
SL 4
SL 1
LR 0,A
LR A,S
SR 4
AS 0
NS 3
LR 3,A
PK
*Subroutine to add to MOBILITY, and to store MOVE and FLAG bytes if necessary
STMV LR K,P
LISU KLOC
LISL 4 To MOVE byte
LR A,3 GET newly computed MOVE byte
LR 0,A
PI CAQ Count its bits
AS 2 Add earlier counts
LR 2,A and store
LR A,11
SR 4
CI H'01' Is this the player's board
BNZ STM3
DCI PLMV Player's possible moves are stored separately
LM
INC
INC Entries take two bytes
DCI PLMV
ST
AI H'FE' Subtract 2
ADC
BR STM4
STM3 LR A,S Has a move byte been stored?
NS S To set status byte
BNZ STM2 One is already stored
LR DC,H Get back in step (may not be necessary)
LIS H'C' To get to MOVE byte
ADC
STM4 LR A,3
ST Store MOVE byte in RAM
LR I,A Also put it in SC record as a flag
LR A,4 Get the byte pointer
SL 1
SL 1
AS 5
ST Put this into RAM
LR DC,H May be necessary
STM2 PK
*Subroutine to clear space for listing player's possible moves temporarily
CLPM LR K,P
XDC
DCI PLMV This space is also used by TREE routine
LIS H'F'
LR 0,A
CLR
ST
DS 0
BP *-2
XDC
PK
* NEXT FIND RFJ LFJ RBJ LBJ
*
NEXT CLR
LR 6,A Set for normal back up
LR DC,H
LIS H'D' Get to byte number info
ADC
LR A,11 Check for multiple jump condition
SR 4
AI H'FD' 1 for start offset, 2 ply's Mobs. not saved
BM NEX2 Can not be a continuation
XDC Save location
DCI MOBS
ADC
LM
NI H'7' Is flag set?
XDC
BZ NEX2 No multiple jump
*The moving piece byte and byte number is stored in the next earlier block
XDC
LR DC,H
LI H'FC' Back up to get info
ADC
LM
LR 3,A The byte with 1 bit on
LM
LR 4,A The byte number
XDC Now back again to the current block
LIS H'1' The signal read by GMEN
LR 6,A Overwrite previously set value
NEX2 LM Get identifying data
LR 0,A Save temporarily
NI H'F' Leave J bit and other data off
CI H'F' Is this the last move byte?
BZ NEX5 Yes
LR A,0
INC To next direction
LR 0,A
SR 1
SR 1
NI 3
LR 4,A Save byte number
LR A,0 Now get the direction
NI 3 Separate out desired data
LR 5,A And save (it will be a 1, 2, or 3)
LR A,0
NI H'10' Check jump bit
BNZ NEX4 A jump move
LR A,5
NS 5
BZ NEX3
JMP RBN0 A normal move, decide on 1, 2, or 3 later
NEX3 JMP RFN It was 0
NEX5 JMP AFT
NEX4 LR A,5
NS 5
BZ RFJ It was a 0
CI H'2' Which direction, 1, 2, or 3?
BM LBJ It was a 3
BNZ LFJ It was a 1
BR RBJ It was a 2
*We enter here on going forward
FIND LISU PLOC
LISL 0 Start with byte 0
CLR
LR 4,A Used to distinguish byte
LR 2,A Used to accumulate mobility count by STMV
LI H'FF'
LR 6,A So all moves will be found
RFJ PI GMEN
PI FKT Are there forward moving pieces?
PI FJET Are jump moves in this direction posible?
SR 1
NI H'77' Save 6 particular bits only
NS 3
LR 3,A Only pieces that have place to land
LR A,4 Get byte number
AI ISP Start of passive area
LR IS,A
PI RFJN This returns the RFJ byte in 3 and sets STATUS
BZ LFJ
LI H'10' The RFJ direction and J indicator
LR 5,A
PI STMV Store MOVE and FLAG if MOVE found
BR JUMF
LFJ PI GMEN
PI FKT
PI FJET Are jump moves in this direction posible?
SL 1
NI H'EE' Save 6 particular bits only
NS 3
LR 3,A Only pieces that have a place to land
LR A,4 Get byte number
AI ISP Start of passive area
LR IS,A
PI LFJN This returns the LFJ byte in 3
BZ RBJ
LI H'11' The LFJ direction and J indicator
LR 5,A
PI STMV
BR JUMF
RBJ0 LR A,5
CI H'2' Which direction, 1, 2, or 3?
BM LBJ It was a 3
BNZ LFJ It was a 1
RBJ PI GMEN
PI BKT
PI BJET
SR 1
NI H'77' Save 6 particular bits only
NS 3
LR 3,A
LR A,4 Get byte number
AI ISP Start of passive area
LR IS,A
PI RBJN This returns the RBJ byte in 3
BZ LBJ
LI H'12' The RBJ direction and J indicator
LR 5,A
PI STMV
BR JUMF
LBJ PI GMEN
PI BKT
PI BJET
SL 1
NI H'EE' Save 6 particular bits only
NS 3
LR 3,A
LR A,4 Get byte number
AI ISP Start of passive area
LR IS,A
PI LBJN This returns the RBJ byte in 3
BZ JUMT
LI H'13' The RBJ direction and J indicator
LR 5,A
PI STMV
JUMF LR A,11 Where are we?
SR 4 To get the ply
CI H'1' Remember offset
BNZ JUMD
JMP PMRT Check players move for validity
JUMD CI H'F' Are we out of space? (next block contains MOBS)
BZ RFN To compute non-jump mobility and stop anyway
LR DC,H
JMP SELE
* JUMT AFTC
*
*No move found from this byte so see if there are more bytes
JUMT LR A,6
*Are we backing up and then trying to find yet another continuation?
CI H'1' Are we backing up to a possible fork
BZ AFTC Yes so something special is required
CI H'7' Were we trying to find a continuation
BNZ JUMM No
LR DC,H There was no continuation
LI H'F0' Back up
ADC
LR H,DC
JMP DOUX This changes the color and proceeds
JUMM LR A,4
INC
NI H'3'
LR 4,A
BNZ RFJ Go round again for next byte
LR A,6
XI H'FF'
CLR
LR 4,A Prepare to start over on the first byte
BZ RFN Maybe there are normal moves
JMP AFT A jump was demanded so back up
*We compare the score with that 2 blocks earlier and back it up if greater
*and then back to this level in any case
AFTC LR DC,H
LIS H'E'
ADC
XDC
LR DC,H
LI H'E0'
ADC
LR H,DC
LIS H'E'
ADC
XDC
LM
LR 0,A Save it
XDC
CM
BM AFT2 Score should be backed
BZ AFT3 Further testing indicated
AFT5 JMP SELE
AFT2 XDC
LM
LR 1,A
BR AFT4
AFT3 XDC
LM
LR 1,A
XDC
CM
BP AFT5 Do not back score
AFT4 XDC
LI H'FE'
ADC
LR A,0
ST
LR A,1
ST
BR AFT5
* AFT MAKE OKMV PMRT
*
*No moves found so time to back up
AFT LR DC,H
LIS H'E' Get to SCORE
ADC
LM
LR 0,A The current material advantage term
LM
LR 6,A The current positional term
LR A,11 Where are we?
SR 4
CI H'2'
BZ MAKE Time to report move
CI H'3' Room to alpha-beta prune?
BP AFTX No
LR DC,H
LI H'EE' The score for 2 boards earlier
ADC
JMP EV4A
AFTX JMP EVA5
*
*Prepare for analysis of player's reply
MAKE DCI TREE Get to players board
LR H,DC
XDC Now clear space for possible players moves
DCI PLMV This space is also used by TREE routine
LIS H'F'
LR 0,A
CLR
ST
DS 0
BP *-2
XDC
PI RASC Put board into SC
JMP FIND
*Subroutine to save players possible moves
SVPM LR K,P
XDC So we can get back
LR A,5
NI H'10'
DCI PLMF Players jump move flag
ST
LR A,4
SL 1
SL 1
AS 5
NI H'F' Save only last 4 bits
DCI PLMV This area may be overwritten by tree info.
ADC
LR A,3
ST
XDC
PK
PMRT NOP Player's possible moves have been listed
*We are ready to display the new board
**** DISPLAY CODE GOES IN HERE
*We are ready to verify players move
OKIT DCI PLMV Location where players move began
**** INIT JOYSTICK and wait for players indication that he has picked
***piece to move then go to OKPI and then to OKMV
* RFN LFN RBN LBN NORT NORF NOR2 NOR3 NOR4
*
RFN PI GMEN
PI FKT
BZ RBN
LR A,4 Get byte number
AI ISE Start of empty region
LR IS,A
PI RFJN
BZ LFN
CLR
LR 5,A
PI STMV
LR A,6
XI H'FF'
BNZ NORF
LFN PI GMEN
PI FKT
BZ RBN
LR A,4 Get byte number
AI ISE Start of empty region
LR IS,A
PI LFJN
BZ RBN
LIS H'1'
LR 5,A
PI STMV
LR A,6
XI H'FF'
BNZ NORF
BR RBN
RBN0 LR A,5
CI H'2' Which direction, 1, 2, or 3?
BM LBN It was a 3
BNZ LFN It was a 1
RBN PI GMEN
PI BKT
BZ NORT
LR A,4 Get byte number
AI ISE Start of empty region
LR IS,A
PI RBJN
BZ NORT
LIS H'2'
LR 5,A
PI STMV
LR A,6
XI H'FF'
BNZ NORF
LBN PI GMEN
PI BKT
BZ NORT
LR A,4 Get byte number
AI ISE Start of empty region
LR IS,A
PI LBJN
BZ NORT
LIS H'3'
LR 5,A
PI STMV
LR A,6
XI H'FF'
BZ NORT
NORF JMP SELE
*We get here if we want to compute mobility and also if no moves found
NORT LR A,4
INC
NI H'3'
LR 4,A
BNZ RFN Go round again for next byte
LR A,2 Get mobility count
NS 2
BNZ NOR1
JMP AFT Woops! no move found
NOR1 LR A,11 Where are we?
SR 4 Get Ply number
AI H'FF'
LR 3,A
BNZ NOR2
JMP PMRT Ckeck players move for validity
NOR2 XDC
DCI PLY0 Neg. of ply test value stored here
LM
XDC
AS 3
BM NOR4 Go on for sure
AI H'FE'
BP NOR3 Time to evaluate for sure
LI H'F5' Decision based on previous move
ADC
LM
NI H'10' Test jump flag
LR DC,H
BNZ NOR4 Go on if previous move was a jump
NOR3 JMP EVAL
NOR4 LR A,3
NOR5 AI H'FD' To save space so MOBS will not overflow
BM NOR7 Don't save mobility for early plys
DCI MOBS
ADC
LR A,2
CI H'F' Limit mobility to 15 so it will pack
BP NOR6
LIS H'F'
NOR6 SL 4 Reserve right half for Multiple jump flags
ST Save mobility in MOBS space indexed by ply
NOR7 LR DC,H Get back in step
JMP SELE
* SELECT SELE
*
*SELECT branches to NEXT if MOVE is empty, or it extracts the rightmost
*bit from the MOVE byte in RAM, storing the extracted bit in SC 6, puts the
*FLAG byte in SC 7, the byte number in 4, and the J and direction bits in 5.
*and proceeds to make the selected move.
SELE LR DC,H Load DC with starting location for current ply
PI RASC Get board data into Scratchpad
SEL2 LR DC,H
LIS H'C' To get MOVE byte
ADC
LM
LR 0,A Save it temporarily
NS 0 To set status byte
BNZ SEL3
JMP NEXT To get next MOVE byte
SEL3 LI H'FF'
ADC Get back to move byte
LR A,0
AI H'FF' Really subtracting 1
NS 0 Remove right-most on-bit
ST Put remaining bits back (and index)
XS 0 This gets the extracted bit
LR 6,A Save it in 6
**** A record of the serial number of this move should be kept for ply 0
**** and put with the resulting board, for use in identifying path for book moves.
LM Now get the byte designation
LR 5,A
SR 1
SR 1
NI H'3' Separate the byte indicator part
LR 4,A Save it in 4
LR A,5
NI H'13' Separate the JUMP bit and the direction
LR 5,A Save them in 5
*Now process ACTIVE and KINGS for source deletion
DELE PI GMEN
XS 6 Delete moving piece
LR S,A from byte
LISU KLOC To get to corresponding KING byte
LR A,S
NS 6 Was the piece a king?
BZ DEL2
XS S If it was delete king bit
LR S,A
LIS H'7' Non-zero in 2 for king
DEL2 LR 2,A Save as a flag for kind of piece moving
*Now locate captured piece if jump or find destination in normal move
LR A,6 Recall MOVE bit
SR 4
BZ INRH Bit was in right half of byte
INLH LR 3,A Save partially shifted MOVE bit
LR A,5 Get direction
NI H'1' To test right-most bit
BZ INL2 RF or LB move where 4 shift is correct
LR A,3
SR 1 LF and LB require an additional shift
LR 3,A
INL2 LR A,5 Now test for fore or aft
NI H'2'
BZ BOTH Forward move, no byte shift needed
LR A,D Only to decrement ISAR
INL3 BR BOTH
*
INRH LR A,6 Get MOVE bit again
SL 4 Left shift if in right half
LR 3,A Save partially shifted MOVE bit
LR A,5 Get direction
NI H'1'
BNZ INR2 LF or RB wwhere 4 shift is correct
LR A,3
SL 1 RF and RB require an additional shift
LR 3,A
INR2 LR A,5 Now test fore and aft
NI H'2'
BNZ BOTH
LR A,I Only to increment ISAR
*Now we are ready to decide if jump or not
BOTH CLR
LR 0,A Used temporarily to accumulate piece debit
LR A,5 Now is this a jump or a normal move?
SR 4
BNZ BOT1
JMP NORM It's a normal move
BOT1 JMP JUMP
* JUMP
*
JUMP LR A,S Get King Byte corresponding to captured piece
NS 3 Was piece a king?
BZ JUM1 No
XS 3 Delete it
LR S,A And replace byte
LR A,0
INC Count 1 extra for king
LR 0,A
JUM1 LIS H'2'
AS 0 Count 2 for piece capture
LR 0,A
LISU PLOC Get back to right buffer for ACTI and PASS
LR A,IS
AI 4 Increment to PASSIVE byte
LR IS,A
LR A,S Get appropiate PASSIVE byte
XS 3 Delete capture
LR S,A And return byte
LISU PLOC Back to moved-from location
LISL 0
LR A,IS
AS 4 Byte number is in 4
LR IS,A
LR A,5 Get direction
NI H'1' Test for right or left
BZ JUM2
LR A,6 It's to the left
SR 1 Left moves involve a right shift of 1
BR JUM3
JUM2 LR A,6 It's to the right
SL 1 Right moves involve a left shift of 1
JUM3 LR 3,A Save displaced bit in 3
LR A,5
NI H'2' Test for fore or aft
BZ JUM4 Fore move
LR A,D Decrement ISAR (destination always in next byte)
LR A,4
AI H'FF' Correct to destination byte number
LR A,2 Was the piece a king?
NS 2
BNZ JUM6 Yes, so not necessary to test for a promotion
LR A,IS Backward non-king must be white
CI O'30' Is this WHITE's king row
BNZ JUM7 No, so there may still be a double jump
BR JUM5 Promotion indicated, so no double jump possible
JUM4 LR A,I Increment ISAR
LR A,4
AI H'1' Correct to destination byte number
LR 4,A We'll need this for continuation
LR A,2 Was the piece a king?
NS 2
BNZ JUM6 Yes, so not necessary to test for promotion
LR A,IS Forward non-king must be black
CI O'33' Is this BLACK's king row
BNZ JUM7 No, so there may still be a double jump
*Promotion indicated, do it and set 2 to flag bypass of double jump prepare
JUM5 LIS H'1' Non-zero (but not 7) for promotion
LR 2,A It is so promote piece
LR A,0
INC Add 1 to debit account
LR 0,A
JUM6 LR A,S Now get right byte
AS 3 Insert piece
LR S,A
LR A,IS Prepare to deposit king
AI 7 Go to correct king byte
LR IS,A
JUM7 LISL 4 Get to piece debit position
LR A,S
SR 4 Note that right part is zero'ed
SR 1
AS 0
CI H'7' Limit size to 7
BP JU7M
LI H'7'
JU7M SL 4
SL 1
LR S,A
LR A,2
CI H'1' Was it by promotion?
BZ JUM9 It was, so no double jump prepare
*Now we must anticipate a forked double jump
*See the detailed explanation of multiple jumps on page 3.
LR DC,H Do not advance H yet
LI H'20' Copy data two blocks forward
ADC
LISU PLOC
LISL 0
LIS H'8'
LR 0,A
PI SCRL Active and passive pieces
LISU KLOC
LISL 0
LIS H'4'
LR 0,A
PI SCRL
LIS H'4'
LR 0,A
LR Q,DC
XDC
LR DC,Q
LI H'E0' Last 4 bytes come from current RAM data
ADC
JUM8 LM
XDC
ST
XDC
DS 0
BNZ JUM8
*Now save the board in anticipation of no double jump
JUM9 LR DC,H (Do not yet advance H)
LI H'10'
ADC
PI SCRA
*Now look into double jump situation
LR A,2
CI H'1' Was there a promotion?
BNZ DOUB No, so may be a double jump
LR DC,H Finally ready to advance H
LI H'10'
ADC
LR H,DC
*We get here from FIND (with H reset) if no continuation possible
DOUX LR A,7
COM
LR 7,A
JMP FIND
DOUB LR DC,H Advance H by 2
LI H'1C'
ADC
LR A,3 Needed if continuation is successful
ST It will be overwritten if not
LR A,4
ST
LR DC,H
LI H'20'
ADC
LR H,DC
LR A,11
SR 4
XDC
DCI MOBS
AI H'FD' stored back by 3
ADC Will never be too early
LIS H'F' Used to signal a continuation
LR 6,A
ST Set continuation signal
XDC get back
PI RASC Load scratchpad
JMP RFJ
* NORM FORE
*
*Now make normal move
NORM LISU PLOC Get back to Active pieces
LR A,S
AS 3
LR S,A Put in moved piece
LR A,2 Was it a king
NS 2
BNZ NOM6 Yes so don't promote but do put king down
LR A,5
NI H'2' Test for direction
BZ NOM4 Black is active
LR A,IS
CI H'30' Did it get to the white king row?
BZ NOM5 Yes, so promote
BR FORE
NOM4 LR A,IS Black is active
CI H'33' Did it get to the king row?
BNZ FORE No
NOM5 LIS H'1'
LR 0,A
NOM6 LISU KLOC Now get to king byte
LR A,S Get corresponding king byte for destination
AS 3 Insert king
LR S,A And replace byte
LR A,0
NS 0
BZ FORE
LISL 4 Now fix the piece debit
LR A,S
SR 4
SR 1
INC
CI H'7'
BP NOM7
LI H'7'
NOM7 SL 4
SL 1
LR S,A
FORE LR DC,H
LI H'10'
ADC To next board record
LR H,DC
PI SCRA Save newly created board record
LR A,7
COM Reverse color
LR 7,A
PI RASC Get correct board into SC
JMP FIND
* EVAL
*
EVAL LR A,11 We'll need the ply value
SR 4
AI H'FF'
LR 5,A We'll need it again
AI H'FD' MOBS indexes 2 less and we want one earlier
LR DC,H
ADC
LM Get earlier mobility
SR 4 It was shifted to pack
COM
INC
AS 2 Add current mobility
CI H'7' Difference limited to absolute 7
BP EVAA
LI H'7'
EVAA CI H'F9'
BM EVAB
LI H'F9'
EVAB SL 4 Make room for ply term
LR 6,A Save difference (and free 2)
*Now look to the first term
LR DC,H Make sure this is correct
LIS H'C' To get current board piece debit
ADC
LISU KLOC
LISL 5 To get previous board piece debit
LR A,I
SR 4
SR 1
LR 2,A Piece credit for ACTIVE
LM Now the current board
SR 4
SR 1
LR 1,A Piece credit for PASSIVE
LR 0,A Save it twice
COM
INC Make it a true negation
AS 2
LR 4,A Save for its sign
BZ EVA7 No material advantage
BP EVA2
COM
INC Make it a true negation
LR 1,A
LR A,0 This was the larger
LR 2,A
EVA2 LR A,2
AI 2 Increase larger by 2
LR 2,A
PI MPYR Multiply 2 by 1
LR A,4
NS 4
BP EVA3
LR A,0
COM Note not true negation
INC
LR 0,A The Piece score
LR A,5
BR EVA4
EVA3 LR A,5
COM
INC
EVA4 AS 6 Add in the mobility term
LR 6,A Completed positional term
LR A,5
EV4A CI H'2' Are we far enough along to be able to prune?
BP EVA5 No
LR A,0 Now get material advantage term back
CM Compare with value brought forward 2 levels
BM EVA5 Can not alphe-beta prune
BNZ EVA9 In this case we can for sure
*We have to compare second score terms in this case
LR A,6
CM
BP EVA9 We can prune
EVA5 LR DC,H Otherwise back 1 level
LI H'F0'
ADC
LR H,DC
LIS H'E'
ADC
LR A,0
COM
INC
CM
BM EVA6 Back score for sure
BNZ EVA8 Do not back score for sure
LR A,0
COM
INC
CM
BP EVA8 Do not back score
EVA6 LR DC,H
LIS H'E'
ADC Get back to first score term
LR A,0
COM
INC
ST
LR A,6
COM
INC
ST
LR A,5 Where are we?
CI 2
BNZ EVA8 Not going back to the first board
LI H'10' Prepare to save this board
LR 0,A
LR DC,H
EVA7 LM
LR 1,A
LI H'DF'
ADC
LR A,1
ST
LI H'E0'
ADC
LR A,0
AI H'FF'
LR 0,A
BNZ EVA7
EVA8 LR DC,H
LI H'F0'
ADC
LR H,DC
JMP SELE
EVA9 NOP **** This code needs fixing
* SQIN SQOU MVIN
*
*Subroutine to accept a square number in std. checker notation in SC 1 and
*to return a byte number in SC 2 and a MOVE byte (with 1 bit on) in SC 3.
*SC 0 is used.
SQIN LR K,P
LR A,1
AI H'FF' Change range to 0 thru 31
LR 0,A
SR 1
SR 1
SR 1 Divide by 8
LR 2,A This is the byte number
LR A,0
NI H'7'
LR 0,A
LI H'80' A bit in position 7 (squares 1, 9, 17 or 25)
BR SQI2
SQI1 LR A,3
SR 1
SQI2 LR 3,A
LR A,0
AI H'FF'
LR 0,A
BNZ SQI1
PK
*
*Subroutine to accept a byte number in 2 and a MOVE byte in 3 and to return
*a square number in standard checker notation in 1.
*
SQOU LR K,P
LR A,2
SL 1
SL 1
SL 1 Multiiply by 8
LR 1,A
SQO1 LR A,1
INC
LR 1,A
LR A,3
SL 1
LR 3,A
BP SQO1
PK
*
*Subroutine to analyse an input move (received as two numbers in 1 and 2)
*and to verify that the move is acceptable.
*
*The general scheme is to verify certain aspects of the proposed move and
*to extract the direction indicator from it. A call to FIND will then verify
*that this move is indeed possible.
*
****THIS CODE IS MUCH TOO LONG. THERE MUST BE A BETTER WAY.
**** We must also decide on the number of messages that we may want to
*generate. This code assumes only three: 1) "You must JUMP", 2) "Try again",
*or perhaps "Illegal move" and 3) "O.K.".
*
MVIN CLR
LR 11,A
LR DC,H
LIS H'E'
ADC
LM
NI 1 Extract J
LR 3,A Save as required Jump flag
LR A,1
COM
INC
AS 2
LR 4,A Save for front or back move signal
BP MVI2
COM
INC
MVI2 LR 5,A Save magnitude of difference
CI 6
BM MVJ1 Seems to be a jump move
LR A,1
NI 1
BZ MVN2 Normal move called for
JMP ERR1 An error, Jump is required
MVN2 CI 3
BZ MVN3 Must be RF or LB
CI 5
BZ MVN4 Must be LF or RB
CI 4
BZ MVN5 Can not decide yet
JMP ERR2 An error, normal move required
MVN5 LR A,1
AI H'FF' Subtract 1
NI 4 Which half of byte
BNZ MVN4 Must be LF or RB
MVN3 LR A,4 A RF or LB
NS 4
BM MVN6
CLR RF
BR MVI3
MVN6 LIS H'3' LB
BR MVI3
MVN4 LR A,4
NS 4
BM MVN7
LIS H'1' LF
BR MVI3
MVN7 LIS H'2' RB
BR MVI3
*
MVJ1 LR A,1
NI 1
BNZ MVJ2
JMP ERR2 An error, normal move required
MVJ2 LR A,5
CI H'7'
BZ MVJ3 It's either RFJ or LBJ
CI 9
BZ MVJ5 It's either LFJ or RBJ
JMP ERR1 An error, jump is required
MVJ3 LR A,4
NS 4
BM MVJ4
LI H'10' RFJ
BR MVI3
MVJ4 LI H'13' LBJ
BR MVI3
MVJ5 LR A,4
NS 4
BM MVJ6
LI H'11' LFJ
BR MVI3
MVJ6 LI H'12' RBJ
BR MVI3
MVI3 LR 0,A Save temporarily
**** Now we must fix matters so that FIND may be called to see if this is
*a legel move
**** Then we do the following
*
PI SQIN Get byte number into 2 and move byte into 3
LR DC,H
PI RASC
LR DC,H
LR A,3
LR 6,A
*
LR A,2
SL 1
SL 1
AS 0 THIS HAS THE JUMP BIT IN H'10'
*
ERR1 NOP **** Must send error message
ERR2 NOP **** Must send error message
**** This has the JUMP bit in the original FLAG byte
**** We are about ready to enter SELECT at DELE but some fixing necessary
* TELL
* Subroutine to get machine's move into standard checker notation
TELL LR K,P
PI PUSH
CLR
LR 0,A **** IS THIS RIGHTT
PI TELX
LR 2,A Save bits that differ
COM
INC
NS 2
LR 3,A This is one bit
NS 1 Is it the destination?
BZ TEL1
LI H'10'
TEL1 LR 4,A The destination signsl
LR A,0
COM
AS 4
LR 4,A In this byte
LR A,3
NS 1 Is there another? ***** CHECK THIS
BNZ TEL2 There is
PI TELX
TEL2 LR 5,A The second bit
NS 1
BZ TEL3
LIS H'10'
TEL3 LR 6,A
LR A,0
COM
AS 6
LR 6,A
PI POPS
PK
TELX LR K,P
LM Get passive byte from players board
LR 1,A
XDC
XM XM with active byte from machines board
XDC
DS 0
BZ TELX No change in this byte
PK
* BOOK
*Code to read stored book moves
*
BOOK DCI TREE
LR H,DC
XDC
DCI STOR
*Opening move table (choice to be made by a random number from 0 thru 7
BOK1 DC H'01' 12-16, 11-15
DC H'23' 10-14, 9-13
DC H'45' 11-16, 10-15
DC H'61' 9-14, 11-15
*First replies (maximum of 4 each)
BOK2 DC H'33' 24,20 24-20 To 12-16
DC H'33' 24-20, 24-20
BOKB DC H'43' 23-19, 24-20 To 11-15
DC H'20' 22-17, 24-19
BOKC DC H'22' 22-17, 22-17 To 10-14
DC H'22' 22-17, 22-17
BOKD DC H'55' 22-18, 22-18 To 9-13
DC H'55' 22-18, 22-18
BOKE DC H'31' 24-20, 23-18 To 11-16
DC H'45' 24-19, 22-18
BOKF DC H'66' 21-17, 21-17 To 10-15
DC H'66' 21-17, 21-17
BOKG DC H'55' 22-18, 22-18 To 9-14
DC H'55' 22-18, 22-18
*First counter replies (maximum of 2 each)
BOK3 DC To 12-16 24-19
DC To 12-16 23-18
DC To 12-16 22-17
DC H'00' 8-12, 8,12 To 12-16 24-20
DC H'00' 16-23, 16,23 To 12-16 23-19
DC To 12-16 22-18
DC To 12-16 21-17
DC H'00' 15-24, 15-24 To 11-15 24-19
DC H'00' 8-11, 8-11 To 11-15 23-18
DC H'60 9-13, 8-11 To 11-15 22-17
DC H'00' 8-11, 8-11 To 11-15 24-20
DC H'05 8-11, 9-14 To 11-15 23-19
DC H'00' 15-22, 15-22 To 11-15 22-18
DC To 11-15 21-17
**** THERE WILL BE 49 BYTES OF THESE, EACH WITH 2 COUNTER REPLIES
**** The ones listed at present are from Lee's Guide
* MEN KING REDP BLKP
*
* Code to read the internal representation of the board and to put the
* required pieces into the board image.
*
*This code requires a minimum of subroutine nesting and of space but it is
*slow. Speed should not be important since the code is used only twice
*per move. It presently requires 147 bytes (115+32).
*
MEN LISU O'3' Start with pieces
LIS H'1' 1 for red pieces (shown first always)
LR 4,A To specify piece color (1 red, 0 black, -1 king)
LR A,7 Get color of active
NS 7 Set status
LISL O'7' Decrement if black is active and shift right
BZ MEN1 Black is active (Appears at bottom of screen)
LISL O'0' Red is active, increment and shift left
MEN1 LIS H'3'
LR 1,A To count bytes
LIS H'7'
LR 2,A To count bits
MEN2 DCI TAB1 Starting address for the byte location table
LR A,1 This byte number
SL 1 Locations occupy 2 bytes each
ADC
LM Get the location
LR QU,A and save it in Q
LM
LR QL,A
LR A,7
NS 7
BZ MEN5 Black is active
LR A,I Increment if red is active
BR MEN4
MEN3 LR A,3
SL 1 and shift left
MEN4 LR 3,A
NI H'80' (done this way for symetry, BC would work)
BZ MEN9
BR MEN8
MEN5 LR A,D Decrement if black is active
BR MEN7
MEN6 LR A,3
SR 1 and shift right
MEN7 LR 3,A
NI H'1'
BZ MEN9
MEN8 DCI TAB2 Relative-locations-of-squares table
LR A,2 This square
ADC
LM Get square displacement
LR DC,Q Recall the location for the input byte
ADC This is the square position
LR A,4 Identify type of piece
NS 4
BM PUTK To put down a king
LIS H'4' Prepare for a piece
LR 5,A To count lines
LI H'20' Skip the first 4 lines (4*8)
ADC
XDC
DCI BLKP Anticipate a black piece
BZ PUTL A black piece (status bit still ok)
DCI REDP No, it's a red piece
BR PUTL
PUTK LIS H'2' Only 3 lines for a crown
LR 5,A
LIS H'8' To skip 1 line
ADC
XDC
DCI KING
PUTL LM Put loop
XDC
ST
LIS H'7' To next line on screen (less increment)
ADC
XDC
DS 5
BP PUTL Loop
MEN9 DS 2
BM ME10
LR A,7
NS 7
BZ MEN6 Black active case
BR MEN3 Red active case
ME10 DS 1
BP MEN2 For the next input byte
LR A,4
NS 4
BM BDEX Exit from board routine
DS 4
BP MEN1 Go round again for black pieces
LISU H'4' Get set for kings
LR A,7
NS 7
LISL H'3' Decrementing case
BZ MEN1
LISL H'0' Incrementing case
BR MEN1
BDEX NOP **** THIS CODE MUST INTERFACE WITH GULI'S CODE
TAB1 DC H'0F10' Byte 3 location (a 2 bytes entry)
DC H'0D70' Byte 2 location
DC H'0CD0' Byte 1 location
DC H'0C30' Byte 0 location
TAB2 DC D'86' Relative-square-position table
DC D'84'
DC D'82'
DC D'80' Second row of squares starts here
DC D'07'
DC D'05'
DC D'03'
DC D'01' First playable square off-set
KING DC B'01011010' King's crown representation
DC B'00111100'
DC B'00111100'
REDP DC B'00111100' Red piece representation
DC B'01111110'
DC B'01111110'
DC B'01111110'
DC B'00111100'
BLKP DC B'00111100' Black piece representation
DC B'01000010'
DC B'01000010'
DC B'01000010'
DC B'00111100'
POIN DC B'00001100' Pointer representation
DC B'00000110'
DC B'00000011'
DC B'00000001'
*MAP Code to convert joystick reading into cursor position on board.
*Cursor's position on the board image is limited to the playing squares.
*When the joystick is moved the cursor jumps from playing square to
*playing square, always landing on that square that is nearest to the
*indicated joystick position.
*
*Requires X and Y readings from joystick in 1 and 2 respectively.
*Returns byte in 3 (with one bit on for square) and byte number in 4 and
*puts cursor into board image. Note that the board and its pieces image
*must be regenerated to remove the trace of the cursor' former positions.
*Uses reg 0 in addition to 1, 2, 3, and 4.
MAP LR K,P
LR A,1 X coordinate assumed to be in 1
LR 0,A
PI MAPA Reduce range to 0 thru 24 and invert if necessary
LR A,0
LR 1,A
LR A,2 Y coordinate assumed to be in 2
LR 0,A
PI MAPA Reduce range and invert if necessary
LR A,0
LR 2,A
AS 1
LR 3,A Unnormalized sum in 3
LIS H'8' Need 7 catagories for the sum
LR 0,A
LR A,3
MAP2 DS 0
AI H'F9' Sub 7
BP MAP2
LR A,0
LR 3,A Sum into 3, range 0 thru 6
LR A,1
COM
AI D'25'
AS 2
LR 4,A Unnormalized difference in 4
LIS H'9' Need 8 catagories for the difference
LR 0,A
LR A,4
MAP3 DS 0
AI H'FD' Sub 3
BP MAP3
LR A,0
LR 4,A Difference into 4, range 0 thru 7
COM
INC
AS 3
INC
LR 1,A Normalized X value
LR A,4
AS 3
INC
SR 1
LR 2,A Normalized Y value
NI H'06' Get rid of the lowest order bit
SL 1 Put it into the expected position
LR 4,A The byte number left in 4 shifted left by 2
LR A,1
SR 1
INC
LR 3,A
LIS H'8'
BR MAP5
MAP4 SR 1
MAP5 DS 3
BNZ MAP4
LR A,1
NI H'1'
BNZ MAP6
LR A,3
SR 4
LR 3,A
MAP6 NOP Byte with bit on left in 3
LR A,1
SR 1
LR 1,A
LR A,2
NI H'1'
BZ MAP7
LR A,1
AI H'4'
LR 1,A This is now the offset in the byte
MAP7 NOP
DCI TAB1
LR A,4
SL 1
ADC
LM
LR QU,A
LM
LR QL,A
LIS H'4'
LR 5,A
DCI TAB2
LR A,1
ADC
LM
LR DC,Q
ADC
XDC
DCI POIN
PUTP LM
XDC
OM
LR 0,A
LI H'FF'
ADC
LR A,0
ST
LIS H'7'
ADC
XDC
DS 5
BP PUTP
PK
*
*Subroutine to reduce range and invert if necessary
MAPA LR K,P
LR A,0 Reduce range
SR 1
SR 1
SR 1
LR 0,A
LR A,7 Check color
NS 7
BNZ MAPB Do we need to invert?
LR A,0
COM
AI D'25'
LR 0,A Low bytes at bottom with player playing black
MAPB PK
*
*
* Code to verify that indicated piece can, in fact, move.
* The byte showing the piece is in 3 and the byte # is in 4 without
* the jump bit and the direction as yet.
OKPI DCI PLMV Possible moves listing
LM Number of entries here
ADC
CLR
ST Set zero to stop search
DCI PLMV
LM Skip the number of entries
OKP1 LM Get first move byte
NI H'FF'
BZ OKNO No more entries
NS 3
BNZ OKP2 This might be the one
CM A cheap way to index
BR OKP1 Try again
OKP2 LM Next entry is the byte info
NI H'0C' Remove the J bit and the direction
XS 4 Does it match?
BNZ OKP1 Try again
LR Q,DC
XDC Save data position
DCI PLMD Save data as to starting square
LR A,QU So we can use Q freely if need be
ST
LR A,QL
ST
LR A,1
ST Save the normalized X position
LR A,2
ST and the normalized Y position
LR A,3
ST Save player's starting byte
LR A,4
ST and the Byte number
*We may want to signal the success by some audible signal
JMP **** To the routine that calls MAP
*We will want th indicate failure, perhaps by a growl and then go back
*to letting the player try to find a piece that can move
OKNO NOP
* We have found that the piece can move but we do not yet know the
*intended direction and there may be more than 1 direction possible.
**** NOW FOLLOW THE JOYSTICK AND WAIT FOR ANOTHER HIT.
OKMV DCI PLMD
LM
LR QU,A
LM
LR QL,A
LM Get the old X value
COM
INC
AS 1 This gives us the change in X
LR 5,A
LM Get the old Y value
COM
INC
AS 2
LR 6,A
BM OKM4
CI H'01'
BZ OKM2 It was a normal forward move
CI H'02'
BNZ NONO Not a legal move
LR A,5
CI H'02'
BNZ OKM1
LI H'10' A RFJ move
BR OKN Still must make sure
OKM1 CI H'FE'
BNZ NONO
LI H'11' A LFJ move
BR OKN
OKM2 LR A,5
CI H'01'
BNZ OKM3
CLR A RFN move
BR OKN
OKM3 CI H'FF'
BNZ NONO
LIS H'01' A LFN move
BR OKN
OKM4 CI H'FF'
BZ OKM6
CI H'FE'
BNZ NONO
LR A,5
CI H'02'
BNZ OKM5
LI H'12' A RBJ jump
BR OKN
OKM5 CI H'FE'
BNZ NONO
LI H'13' A LBJ jump
BR OKN
OKM6 LR A,5
CI H'01'
BNZ OKM7
LI H'01' A RBN move
BR OKN
OKM7 CI H'FF'
BNZ NONO
LI H'11' A LBN move
OKN AS 4 Add the byte number
LR 4,A and save the complete byte info
LI H'FF' Back up
ADC
OKN2 LR A,4
CM Is it the same?
BZ OKOK Found!
OKN3 LM Go to the next entry
NI H'FF'
BZ NONO
NS 3
BNZ OKN2 A bit matches here
CM A cheap way to index
BR OKN3
NONO NOP
*We will now have to signal that he has picked a piece that can move but
*it can not move to the square chosen and that the player is to try again
OKOK DCI TREE Now get back to the Tree routine
LR H,DC
LIS H'C'
ADC
LR A,3
ST
LM
NI H'D0'
AS 4
LR 4,A
LI H'FF'
ADC
LR A,4
ST
LR DC,H
*Now we signal success and proceed to make the player's move and go on to
*find the machine's move
* Guli's code
INIT NOP This is in Guli's code
*
UTPR EQU INIT
LINE EQU H'0FD7'
J EQU H'9'
HU EQU H'A'
HL EQU H'B'
AD EQU H'22E5' ADD
WMS EQU H'40A6'
COM EQU H'8F7'
CMRG EQU H'FE2'
DBNC EQU H'FE3'
KR EQU H'4368'
WKM EQU H'25FD'
UDAT EQU H'426E'
*
UPI EQU H'0FFA' UPDATE IMG ROUTINE
OBJ0 EQU H'C30' OBJECT0 H'C30' thru H'E0F'
OBJ1 EQU H'F10' OBJECT1 H'F10' thru H'FAF'
*
*
*Board image generation
BORD LI H'FF'
LR 3,A REG3=0
DCI OBJ0 OBJ0 START
LIS H'2' FLAG FOR BOARD
LR 4,A REG4=2
LIS H'6'
IMG4 LR 0,A REG0=6 ROWS FOR FIRST BRD
IMG3 LIS H'A'
LR 1,A REG1=10 LINES/ROW
IMG2 LIS H'4'
LR 2,A REG2=SQ PAIRS/ROW
IMG1 LR A,3
ST STORE IN BRD IMG
COM NEXT SQ. IN COM. OF PREV.
ST
DS 2
BNZ IMG1 MORE FOR THIS ROW
DS 1 DEC.CNT FOR LINES/ROW
BNZ IMG2 NOT DONE YET
LR A,3 DONE "A" TIMES YET?
COM
LR 3,A
DS 0 DEC ROW CNT
BNZ IMG3 ALL ROWS DONE?
DS 4
BZ IMG5 BOTH OBJECTS DONE
DCI OBJ1 NO, GET OBJ1 ADDRESS
LIS H'2' #OF ROWS IN BRD2
BR IMG4 REG0=2
IMG5 POP
*
*
*
END